
#include <iostream>

using namespace std;

// 请设计一个类，只能在栈上创建对象
class StackOnly
{
public:
	static StackOnly CreateObj()
	{
		return StackOnly();
	}

	void Print() const
	{
		cout << "StackOnly::Print()" << endl;
	}
	//void* operator new(size_t size) = delete;
	//void operator delete(void* p) = delete;

	/*StackOnly(StackOnly&& so)
	{}*/
private:
	StackOnly()
	{}

	StackOnly(const StackOnly&) = delete;
};

int main()
{
	//StackOnly so1 = StackOnly::CreateObj();
	//static StackOnly so4 = StackOnly::CreateObj();

	//static StackOnly so2;
	//StackOnly* pso3 = new StackOnly;

	StackOnly::CreateObj().Print();

	const StackOnly& so4 = StackOnly::CreateObj();
	so4.Print();

	return 0;
}